import React from 'react'
import {Login} from './modules/Login/index'
import {getLoginData} from '../fetch/login/login'
class Lunbo extends React.Component{
    constructor(props,context){
        super(props,context);
        this.state= {
            data:[]
        }
    }
    render(){
        return (
            <div>
                <Login data={this.state.data}/>
            </div>
        )
    }

    componentDidMount(){
        //获取数据
        const result = getLoginData();
        result.then(res=>{
            return res.json()
        }).then(json=>{
            //处理获取的数据
            const data=json
            this.setState({
                data:data
            }).catch(ex=>{
                if(_DEV_){
                    console.error('登录页面获取数据报错')
                }
            })

        })


    }
    componentDidUpdate(){
        const result1 = getLoginData1();
        if(result1=='Y'){
            hashHistory.push('/')
        }else{
            var time=0;
            setInterval(()=>{
                if(time==60) {
                    this.setState({
                        ee:"二维码已过期"
                    })
                    time=0;


                    return;
                }
                time++;
            },1000)
        }
    }
}
export default Lunbo;